package com.devops.admin.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.devops.admin.model.Pagination;
import com.devops.admin.model.TableResult;
import com.devops.admin.model.Tools;
import com.devops.admin.service.ToolsService;
import com.devops.admin.mapper.ToolsMapper;
import com.devops.admin.vo.DOSPageVo;
import com.devops.admin.vo.ToolsVo;
import org.springframework.stereotype.Service;

import java.util.*;

/**
* @author Dell
* @description 针对表【dos_tools】的数据库操作Service实现
* @createDate 2024-03-08 11:39:59
*/
@Service
public class ToolsServiceImpl extends ServiceImpl<ToolsMapper, Tools>
    implements ToolsService{

    @Override
    public Integer addTool(Tools tool) {
        save(tool);
        return tool.getId();
    }

    @Override
    public void updateTool(Tools tool) {
        updateById(tool);
    }

    @Override
    public void deleteTool(Integer toolId) {
        removeById(toolId);
    }

    @Override
    public TableResult<ToolsVo> queryTools(Tools tool, DOSPageVo pageVo) {
        Page<ToolsVo> page = new Page<>(pageVo.getPageNum(), pageVo.getPageSize());
        List<ToolsVo> tools = baseMapper.queryToolsPage(tool, page);
        Pagination p = Pagination.builder().pageNum(page.getCurrent()).pageSize(page.getSize()).total(page.getTotal()).build();
        return new TableResult<>(tools, p);
    }
}




